package com.fr.report.script.core.parser;

import com.fr.base.core.ComparatorUtils;
import com.fr.report.script.Primitive;
import java.math.BigDecimal;

public class OperationUtils
{
  public static final Double POSITIVE_INFINITY = new Double((1.0D / 0.0D));
  public static final Double NEGATIVE_INFINITY = new Double((-1.0D / 0.0D));
  private static final String BOOL = "!";
  private static final String PLUS = "+";
  private static final String MINUS = "-";
  public static final Integer ZERO = new Integer(0);
  public static final BigDecimal BZERO = new BigDecimal(0.0D);

  public static boolean isFalse(Object paramObject)
  {
    return ((paramObject == null) || (paramObject == Primitive.NULL) || (ComparatorUtils.equals(paramObject, Boolean.FALSE)) || (ComparatorUtils.equals(paramObject, new Integer(0))) || (ComparatorUtils.equals(paramObject, "")));
  }

  static boolean booleanUnaryOperation(Boolean paramBoolean, String paramString)
    throws UtilEvalError
  {
    boolean bool = paramBoolean.booleanValue();
    if ("!".equals(paramString))
      return (!(bool));
    throw new UtilEvalError("Operator inappropriate for boolean:\n" + paramString + paramBoolean);
  }

  static int intUnaryOperation(Integer paramInteger, String paramString)
  {
    int i = paramInteger.intValue();
    if ("+".equals(paramString))
      return i;
    if ("-".equals(paramString))
      return (-i);
    throw new InterpreterError("bad integer unaryOperation:\n" + paramString + paramInteger);
  }

  static long longUnaryOperation(Long paramLong, String paramString)
  {
    long l = paramLong.longValue();
    if ("+".equals(paramString))
      return l;
    if ("-".equals(paramString))
      return (-l);
    throw new InterpreterError("bad long unaryOperation:\n" + paramString + paramLong);
  }

  static float floatUnaryOperation(Float paramFloat, String paramString)
  {
    float f = paramFloat.floatValue();
    if ("+".equals(paramString))
      return f;
    if ("-".equals(paramString))
      return (-f);
    throw new InterpreterError("bad float unaryOperation:\n" + paramString + paramFloat);
  }

  static double doubleUnaryOperation(Double paramDouble, String paramString)
  {
    double d = paramDouble.doubleValue();
    if ("+".equals(paramString))
      return d;
    if ("-".equals(paramString))
      return (-d);
    throw new InterpreterError("bad double unaryOperation:\n" + paramString + paramDouble);
  }

  static BigDecimal bigDecimalUnaryOperation(BigDecimal paramBigDecimal, String paramString)
  {
    if ("+".equals(paramString))
      return paramBigDecimal;
    if ("-".equals(paramString))
      return paramBigDecimal.negate();
    throw new InterpreterError("bad bigDecimal unaryOperation:\n" + paramString + paramBigDecimal);
  }

  static Object promoteCharByteShort(Object paramObject)
  {
    if (paramObject instanceof Character)
      return paramObject.toString();
    if ((paramObject instanceof Byte) || (paramObject instanceof Short))
      return new Integer(((Number)paramObject).intValue());
    return paramObject;
  }
}